package com.suns.demo;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class TimerMessageProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("suns-timer-topic-producer");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();
        Message message = null;

        for (int i = 0; i < 1000; i++) {
            Thread.sleep(1000);
            message = new Message("timer_topic_01", ("hello suns timer msg" + i).getBytes());
            message.setDelayTimeSec(7);
            SendResult result = producer.send(message);
            System.out.println(result);
        }
        producer.shutdown();
    }
}
